Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schedule option #573

Merged
merged 8 commits into from
Dec 7, 2020
Merged

Schedule option #573

merged 8 commits into from
Dec 7, 2020

Conversation

oschaaf
Copy link
Member

@oschaaf oschaaf commented Nov 16, 2020

Adds a new schedule option to the proto api., which allows specifying a date/time
at which execution should start.

Should also fix #569 by reducing reliance on Envoy::SystemTime to a minimum:
Based on the value schedule option, a monotonic time will be computed
and propagated. This makes us use Envoy::MonotonicTime again in places
where sub ms resolution is a must have. (The fix will need confirmation, as I
couldn't get --config=libc++ to work for other reasons.)

@oschaaf oschaaf marked this pull request as ready for review November 18, 2020 12:01
@oschaaf oschaaf added the waiting-for-review A PR waiting for a review. label Nov 23, 2020
@dubious90
Copy link
Contributor

@qqustc Please review and assign back to me once ready.

@dubious90 dubious90 requested a review from qqustc November 23, 2020 19:57
qqustc
qqustc previously approved these changes Nov 25, 2020
Copy link
Contributor

@qqustc qqustc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Otto!

@@ -26,7 +29,8 @@ class OutputCollector {
*/
virtual void addResult(absl::string_view name, const std::vector<StatisticPtr>& statistics,
const std::map<std::string, uint64_t>& counters,
const std::chrono::nanoseconds execution_duration) PURE;
const std::chrono::nanoseconds execution_duration,
const absl::optional<Envoy::SystemTime>& first_acquisition_time) PURE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment for first_acquisition_time?

@qqustc
Copy link
Contributor

qqustc commented Nov 25, 2020

@qqustc Please review and assign back to me once ready.

LGTM, assigned back to @dubious90 for review.

@@ -24,7 +24,7 @@ class SequencerFactory {
const SequencerTarget& sequencer_target,
TerminationPredicatePtr&& termination_predicate,
Envoy::Stats::Scope& scope,
const Envoy::SystemTime scheduled_starting_time) const PURE;
const Envoy::MonotonicTime scheduled_starting_time) const PURE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not actionable, just making sure I'm understanding - this is where we're moving back to MonotonicTime to prevent #569 ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is right.

@@ -26,7 +29,8 @@ class OutputCollector {
*/
virtual void addResult(absl::string_view name, const std::vector<StatisticPtr>& statistics,
const std::map<std::string, uint64_t>& counters,
const std::chrono::nanoseconds execution_duration) PURE;
const std::chrono::nanoseconds execution_duration,
const absl::optional<Envoy::SystemTime>& first_acquisition_time) PURE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will likely be addressed when the comment is added, but I'm not sure i understand what acquisition means in this context.

@@ -179,7 +181,10 @@ void ProcessImpl::createWorkers(const uint32_t concurrency) {
// TODO(oschaaf): Arguably, this ought to be the job of a rate limiter with awareness of the
// global status quo, which we do not have right now. This has been noted in the
// track-for-future issue.
const auto first_worker_start = time_system_.systemTime() + kMinimalWorkerDelay;
const Envoy::MonotonicTime monotonic_now = time_system_.monotonicTime();
const std::chrono::nanoseconds offset =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I might be misunderstanding but this ternary seems off to me. kMinimalWorkerDelay has the worker offsets baked into it, correct? So, if we are using a scheduled start time, and we aren't using minimal worker delay at all, then we aren't including any worker offsets from each other.

So now, batching behavior of nighthawk acts differently depending on whether or not we are using a schedule which doesn't seem right.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This computes the start of the first worker, we will still be injecting an offset between each worker below. I refactored this for clarity, hopefully it's easier to read now.

@@ -179,7 +181,10 @@ void ProcessImpl::createWorkers(const uint32_t concurrency) {
// TODO(oschaaf): Arguably, this ought to be the job of a rate limiter with awareness of the
// global status quo, which we do not have right now. This has been noted in the
// track-for-future issue.
const auto first_worker_start = time_system_.systemTime() + kMinimalWorkerDelay;
const Envoy::MonotonicTime monotonic_now = time_system_.monotonicTime();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three comments here:

  1. This has gotten complex enough (especially with the long comments above to explain what's going on), that I think it might warrant its own privately scoped function. CalculateWorkerStartTime_ or something?

const auto first_worker_start = time_system_.systemTime() + kMinimalWorkerDelay;
const Envoy::MonotonicTime monotonic_now = time_system_.monotonicTime();
const std::chrono::nanoseconds offset =
schedule.has_value() ? schedule.value() - time_system_.systemTime() : kMinimalWorkerDelay;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. We are heavily explaining the workerdelay behavior here in the comment above. Can we add a one-line comment for how the schedule behavior fits in? For instance, if I am wrong about point 2 above, we should say why the scheduled workers don't need an offset delay.

/**
* @return absl::optional<Envoy::SystemTime> Time of the first acquisition, if any.
*/
virtual absl::optional<Envoy::SystemTime> firstAcquisitionTime() const PURE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might have just missed it in this pull request (if so, please point me to the right file), but while I'm seeing code that writes this field or passes it around, I'm not finding where it's actually used functionally. What is its intended purpose?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dubious90 dubious90 added waiting-for-changes A PR waiting for comments to be resolved and changes to be applied. and removed waiting-for-review A PR waiting for a review. labels Nov 25, 2020
Signed-off-by: Otto van der Schaaf <[email protected]>
@oschaaf oschaaf added the waiting-for-review A PR waiting for a review. label Dec 7, 2020
@oschaaf
Copy link
Member Author

oschaaf commented Dec 7, 2020

@dubious90 Thanks for the feedback, I think I addressed it. Extracted the worker start time & offset calculations into their own methods for clarity. Ready for another round!

@oschaaf oschaaf removed the waiting-for-changes A PR waiting for comments to be resolved and changes to be applied. label Dec 7, 2020
Copy link
Contributor

@dubious90 dubious90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks for the readability changes! It's really easy to follow what's happening now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-for-review A PR waiting for a review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Building with clang's libc++ fails
3 participants